/* eslint-disable react/no-unused-class-component-methods */
import React, { Fragment } from 'react';
import FormItem from '@components/FormItem';
import { Input, Select } from 'antd';
import { WithSearch } from '{{relativePath}}../../../../components/index';

@WithSearch.bind(null, { customForm: true })
export default class extends React.Component {
  onChange = (key, val) => {
    this.props.onSearch(key, val);
  };

  onSearch = false;

  onReset = false;

  render() {
    const { form } = this.props;
    return (
      <>
        <FormItem span={6} label="关键词" colon>
          {form.getFieldDecorator('name')(
            <Input.Search
              placeholder="请输入"
              allowClear
              onSearch={v => {
                this.onChange('name', v);
              }}
            />
          )}
        </FormItem>
        <FormItem span={6} label="测试" colon>
          {form.getFieldDecorator('test')(
            <Select
              allowClear
              style=\{{ width: '100%' }}
              showSearch
              optionFilterProp="children"
              filterOption={(input, option) =>
                option.props.children.toString().toLowerCase().indexOf(input.toLowerCase()) >= 0
              }
              onChange={v => {
                this.onChange('test', v);
              }}
            >
              {this.options.test}
            </Select>
          )}
        </FormItem>
      </>
    );
  }

  get options() {
    const renderOption = opts =>
      opts.map(({ label, value }) => (
        <Select.Option key={value} value={value}>
          {label}
        </Select.Option>
      ));
    return {
      test: renderOption([])
    };
  }
}
